package com.zs.controller;

import com.zs.entity.Customer;
import com.zs.service.CustomerService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/cus")
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    @RequestMapping("/customerReg")
    public String customerReg(Customer customer) {
        customerService.customerReg(customer);
        return "index";
    }

    @ResponseBody
    @RequestMapping("/checkName")
    public String checkName(@Param("name") String name) {
        String cname = customerService.checkName(name);
        if (cname != null) {
            return "true";
        } else {
            return "false";
        }
    }

}
